import Vue from 'vue'
import VueRouter from 'vue-router'
// import Login from '@/views/login/index.vue'
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject) {
    return originalPush.call(this, location, onResolve, onReject)
  }
  return originalPush.call(this, location).catch(err => {
    console.log(err)
  })
}

Vue.use(VueRouter)

// 自己写自己项目的路由
const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/index.vue')
  },
  {
    path: '/',
    name: 'layout',
    component: () => import('@/views/layout/index'),
    children: [
      {
        // 默认子路由
        path: '',
        name: 'home',
        component: () => import('@/views/home/index')
      },
      {
        path: 'qa',
        name: 'qa',
        component: () => import('@/views/qa/index')
      },
      {
        path: 'my',
        name: 'my',
        component: () => import('@/views/my/index')
      },
      {
        path: 'video',
        name: 'video',
        component: () => import('@/views/video/index')
      }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router

// 删除原有的一些东西，字
